#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,m,L,V;
int d[N],v[N],a[N];
int p[N];
vector<pair<int,int> > vec;
void solve(){
    vec.clear();
    scanf("%d%d%d%d",&n,&m,&L,&V);
    for(int i=1;i<=n;i++){
        scanf("%d%d%d",d+i,v+i,a+i);
    }
    for(int i=1;i<=m;i++)scanf("%d",p+i);
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(d[i]>p[m])continue;
        if(a[i]>=0){
            if(1LL*V*V-1LL*v[i]*v[i]>=2LL*a[i]*(p[m]-d[i]))continue;
            int l=1,r=m;
            while(l<r){
                int mid=(l+r)>>1;
                if(p[mid]<d[i]||1LL*V*V-1LL*v[i]*v[i]>=2LL*a[i]*(p[mid]-d[i]))l=mid+1;
                else r=mid;
            }
            cnt++;
            vec.push_back(make_pair(l,m));
        }
        else{
            int ind=lower_bound(p+1,p+m+1,d[i])-p;
            if(1LL*v[i]*v[i]+2LL*a[i]*(p[ind]-d[i])<=1LL*V*V)continue;
            int l=ind,r=m;
            while(l<r){
                int mid=(l+r+1)>>1;
                if(1LL*v[i]*v[i]+2LL*a[i]*(p[mid]-d[i])<=1LL*V*V)r=mid-1;
                else l=mid;
            }
            cnt++;
            vec.push_back(make_pair(ind,l));
        }
    }
    printf("%d ",cnt);
    if(vec.empty()){
        printf("%d\n",m);
        return;
    }
    sort(vec.begin(),vec.end());
    int mn=m+1,ans=m-1;
    for(int i=0;i<(int)vec.size();i++){
        int l=vec[i].first,r=vec[i].second;
        if(l>mn){
            ans--;
            mn=r;
        }
        else{
            mn=min(mn,r);
        }
    }
    printf("%d\n",ans);
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
    int T;
    scanf("%d",&T);
    while(T--)solve();
	return 0;
}
/*
things to check:
1. freopen
2. int / long long
3. array bounds
4. clear when multi-tests
5. MOD
g++ detect.cpp -o detect -Wall -Wextra -Wshadow -Wconversion
*/